home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tp_dmx20.zip / DMX_FILE.PAS < prev    next >
Pascal/Delphi Source File  |  1990-01-15  |  2KB  |  94 lines

  1. Unit DMX_FILE;  { incorporates file access methods into DMX }
  2.  
  3. {$V-,I- }
  4.  
  5. interface
  6.  
  7.  
  8. uses   Dos, DMX2;
  9.  
  10. type
  11.        Dwindow     =  object (DMXwindow)
  12.                         bytesread            : word;
  13.  
  14.                         procedure LoadDataBlock (var Data;
  15.                                                      BuffSize : longint;
  16.                                                  var F );
  17.                         procedure SaveDataBlock (var Data;  var F );
  18.                       end;
  19.  
  20.  
  21. implementation
  22.  
  23.  
  24.   { ─────────────────────────────────────────────────────────────────────── }
  25.  
  26.  
  27. procedure DWindow.LoadDataBlock (var Data;
  28.                                      BuffSize : longint;
  29.                                  var F );
  30. type  bytefile = file of byte;
  31. var   fs  :  longint;
  32. begin
  33.   bytesread := 0;
  34.   If recordsize > 0 then
  35.     recordlimit := BuffSize div (recordsize + phantomdata)
  36.    else
  37.     recordlimit := 0;
  38.   If recordlimit = 0 then
  39.     DiskError := 13  { invalid data }
  40.    else
  41.     begin
  42.     FillChar (Data, BuffSize, 0);
  43.     If filerec (F).mode = fmClosed then
  44.       begin
  45.       Reset (bytefile (F));
  46.       DiskError := IoResult;
  47.       end
  48.      else
  49.       DiskError := 0;
  50.     If DiskError = 0 then
  51.       begin
  52.       bytesread := BuffSize;
  53.       ReadNextBlock (bytefile (F), Data, bytesread);
  54.       If IoError then bytesread := 0;
  55.       end;
  56.     end;
  57.   changemade := False;
  58. end;  { LoadDataBlock }
  59.  
  60.  
  61.   { ─────────────────────────────────────────────────────────────────────── }
  62.  
  63.  
  64. procedure DWindow.SaveDataBlock (var Data;  var F );
  65. type  bytefile = file of byte;
  66. begin
  67.   If changemade and (recordlimit > 0) then
  68.     begin
  69.     If filerec (F).mode = fmClosed then
  70.       begin
  71.       Reset (bytefile (F));
  72.       If IoError then
  73.         begin
  74.         ReWrite (bytefile (F));
  75.         DiskError := IoResult;
  76.         end;
  77.       end
  78.      else
  79.       DiskError := 0;
  80.     If DiskError = 0 then
  81.       begin
  82.       WriteNextBlock (bytefile (F), Data, recordlimit * (recordsize + phantomdata));
  83.       DiskError := IoResult;
  84.       end;
  85.     changemade  := False;
  86.     end;
  87. end;  { SaveDataBlock }
  88.  
  89.  
  90.   { ─────────────────────────────────────────────────────────────────────── }
  91.  
  92.  
  93. End.
  94.